package com.nlscan.qdkit.ui.publico.util;

import com.quvii.qvlib.util.QvEncrypt;
import com.quvii.qvlib.util.QvSpUtil;

/**
 * SharedPreferences工具类 用于快速读写数据
 * Created by yuanpeng.deng on 2017/9/26.
 */

public class SpLanCacheUtil extends QvSpUtil {
    private final static String AUTH_INFO = "ai_";

    private SpLanCacheUtil() {
    }

    public static SpLanCacheUtil getInstance() {
        return SingletonHolder.instance;
    }

    private static class SingletonHolder {
        private static final SpLanCacheUtil instance = new SpLanCacheUtil();
    }

    @Override
    protected String getSharePreferencesName() {
        return "lan_cache";
    }

    public void setLanAuthInfo(String uid, String ip, String authCode) {
        setEncryptValue(AUTH_INFO + QvEncrypt.sha256(uid + ip), authCode);
    }

    public String getLanAuthInfo(String uid, String ip) {
        return getEncryptValue(AUTH_INFO + QvEncrypt.sha256(uid + ip));
    }
}
